
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@page import="com.tss.util.*"%>
<%@page import="com.jedi.*"%>
<%@page import="com.store.*"%>
<%@page import="java.io.File"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="java.sql.Date.*"%>
<%@page import="com.store.TaskMgr"%>
<%@page import="com.store.Task"%>
<%@page import="com.store.TaskDetail"%>
<%@page import ="java.sql.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10201";//察看
String power1_enable_id = "10208";//打分权限
if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}

String cmd       		 = ParamUtils.getParameter(request,"cmd","");
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

List list=null;
String  taskid = ParamUtils.getParameter(request,"taskid","");




String strErr           = "";
TaskMgr taskMgr = new TaskMgr();
String operator_date  = "";
String task_score     = "";

Task task=taskMgr.get(taskid);
if (task == null || task.getTaskid().trim().equals("")) strErr = "此工单信息不存在!";
Pal pal = new Pal();


String poretime = new SimpleDateFormat("yyyy-MM-dd").format(Calendar
					.getInstance().getTime());
if (!cmd.trim().equals("")) {
	operator_date  = ParamUtils.getParameter(request,"operator_date","");
	task_score     = ParamUtils.getParameter(request,"task_score","0");
}


if (cmd.trim().equals("modi") && strErr.trim().equals("")) {

	FormatDate formDate= new FormatDate();
 taskid = ParamUtils.getParameter(request,"taskid","");
	String status = ParamUtils.getParameter(request,"status","");
	operator_date = ParamUtils.getParameter(request,"operator_date","");
	

	if (task.getStatus() >= 3) {
		strErr = "工单已完成，不能再被修改!";
	}

		if (strErr.trim().equals("") && (! just_user.getId().trim().equals(task.getEngineerid()))) {
		strErr = "您没有修改其他人工单的权限!";
	}
	if (strErr.trim().equals("")) {
		
		if (status.equals("1")) {
			task.setAbegindate(formDate.toDate( operator_date));
			task.setStatus(1);
			
			}
		else if(status.equals("2")){
			task.setAenddate(formDate.toDate( operator_date));
			task.setStatus(2);
			
			}
			else{
			strErr="请选择工单状态再确定";
			}
			task.setTaskid(taskid);
			task.modiStatus();
		
		if (task.hasErr()) strErr = task.getErrHtml();
	}
}
if (cmd.trim().equals("scroe")) {

	if (task.getStatus() !=2) {
		strErr = "此工单还没有结束，不能打分!";
	}
	if (strErr.trim().equals("") && !just_user.hasPower(power1_enable_id)) {
		strErr = "您没有打分的权限!";
	}

	if (strErr.trim().equals("")) {
		try {
			Integer.parseInt(task_score);
		}
		catch(Exception ex) {
			strErr = "工分数值应该是整数!";
		}
	}
	if (strErr.trim().equals("")) {
		if (!(0<Integer.parseInt(task_score)&&Integer.parseInt(task_score)<= 10))
			strErr = "分值应该在0到10之间!";
	}
	if (strErr.trim().equals("")) {
		task.setStatus(3); 
		task.setTaskscore(Integer.parseInt(task_score));
		task.setStatus(3);
		FormatDate formateDate= new FormatDate();
		task.setScoretime(formateDate.toDate(poretime));
		task.setScoreman(just_user.getId());
		task.scroe();
		if (task.hasErr()) strErr = task.getErrHtml();
	}
}



%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'task_add.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    
   <link href="style/main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function clk_goback() {

location.href="task_list.jsp?mgh="+operatorForm.pageno.value;
}
function clk_submit() {

	var oForm = document.operatorForm;
	oForm.cmd.value = "insert";
	return true;
}
function clk_modi_submit() {
if (!confirm("确定要修改工单状态？"))
		return;
	var oForm = document.operatorForm;
	oForm.cmd.value = "modi";
	oForm.submit();
}

function clk_score_submit() {
if (!confirm("确定要打分？"))
		return;
	var oForm = document.operatorForm;
	oForm.cmd.value = "scroe";
	oForm.submit();
}

function clk_delete_submit() {
if (!confirm("确定要删除？"))
		return;
	var oForm = document.operatorForm;
	oForm.cmd.value = "delete";
	oForm.submit();
}


function clk_pal_show(taskid,tripfee,spartfee,outefee) {
	right_menu_clk("../analysis_mgt/pal_detail.jsp?taskid=" + taskid+"&tripfeenum="+tripfee+"&spartfee="+spartfee+"&outefee="+outefee);
}
function clk_anaysis(taskid,tripfee,spartfee,outefee) {
	location.href = "../analysis_mgt/pal_add.jsp?taskid=" + taskid+"&tripfeenum="+tripfee+"&spartfee="+spartfee+"&outefee="+outefee;
}
</script>
</head>
<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td >
    <form name="operatorForm" method="post" >
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
       
        
        <tr> 
          <td height="100" align="center" valign="top" style="padding-top:10px;padding-bottom:10px;">
            <table width="98%" border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
				
               <%if (!strErr.trim().equals("")) {%>
              <tr> 
                <td height="24" colspan="3" bgcolor="#D7D7DB" style="padding-left:10px;">
                  错误提示：
                 
                  <font color=red><%=strErr%></font>                </td>
              </tr>
              <%}%>
					<tr>
						<td width="22%" height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">所在区域：</font></td>
						<td width="78%" bgcolor="#EDEDF0"><%=task.getArea_id()%></td>
				    </tr>
						<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工单状态：</font></td>
						<td bgcolor="#EDEDF0">
						<%
						String status_str="";
						if(task.getStatus()==0){status_str="登记";}
						if(task.getStatus()==1){status_str="进行中";}
						if(task.getStatus()==2){status_str="已完成";}
						if(task.getStatus()==3){status_str="结束";}
						%>
						<font color="red"><%=status_str%></font>
						</td>
				    </tr>
				    <tr>
						<td height="22" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工单编号：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"><%=task.getTaskid()%>
						
						<input type="hidden" name="taskid" value="<%=task.getTaskid()%>">
						
						</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工程师姓名：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> <%=task.getEngineername()%></td>
				    </tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">项目经理：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> <%=task.getContract().getTechmanager_name()%></td>
				    </tr>
					
					<tr>
						<td height="22" align="right" bgcolor="#858585"><font
							color="#FFFFFF">客户名称：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
							 <%=task.getCusname()%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">客户联系人：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;">  <%=task.getLinkman()%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">联系电话：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
					 <%=task.getPhone()%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">联系地址：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
						 <%=task.getAddr()%></td>
					</tr>
					
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">所属合同号：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 

						 <%=task.getConid()%>
							</td>
					</tr>
					
					
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">计划服务日期：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
						从
						  <%=task.getBegindate()%> 到 <%=task.getEnddate()%>
                   </td>
					</tr>
					
					<%--<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">实际服务日期：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
				从 <%=task.getAbegindate()%> 到 <%=task.getAenddate()%>
                		</td>
					</tr>
					--%><tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">正常工作量(小时)：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
				 <%=task.getNormaltime()%>
				
				</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">加班工作量(小时)：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 

							 <%=task.getWorktime()%>
							</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">合计工作量(天)：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
							 <%=task.getTasktime()%></td>
					</tr>
					
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">出差地点：</font></td>
					  <td bgcolor="#EDEDF0" style="padding-left:5px;"> 
					 <%=task.getTaskaddress()%>
					</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">出差方式：</font></td>
					    <td bgcolor="#EDEDF0" style="padding-left:5px;"> 
					    <%
					    String tripstring="";
					    if(task.getTriptype()==1){ tripstring="飞机"; }
  					    if(task.getTriptype()==2){ tripstring="火车"; }
   					    if(task.getTriptype()==3){ tripstring="汽车"; }
					      if(task.getTriptype()==4){ tripstring="其它"; }
					    %>
					   <%=tripstring%>
					   </td>
					</tr>
			
					
				
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">差旅费：</font></td>
					  <td bgcolor="#EDEDF0" style="padding-left:5px;"> 
					    <%=FormatNum.formatCurrencycn(task.getTripfee())%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">备件成本：</font></td>
				      <td bgcolor="#EDEDF0" style="padding-left:5px;"> 
				        <%=FormatNum.formatCurrencycn(task.getSpartfee())%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">外部人员技术成本：</font></td>
				      <td bgcolor="#EDEDF0" style="padding-left:5px;"> 
				        <%=FormatNum.formatCurrencycn(task.getOutefee())%></td>
					</tr>
					<%
						String savePath="upload/tasklile";
						String fileName=task.getTasklile();
						File fileSave = new File(pageContext.getServletContext().getRealPath(savePath + "/" + fileName));
			if (fileSave.exists()) {
						%>
						<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工单附件：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 
						
						
					<a href="do_download.jsp?filename=upload/tasklile/<%=task.getTasklile()%>"><%=task.getTasklile()%></a>
					</td>
					
					</tr>
					<%}else{%>
							<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工单附件：</font></td>
						<td bgcolor="#EDEDF0" >此附件已经被删除</td>
					</tr>
					<%}%>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">服务内容：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> <%=task.getMatterinfo()%></td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工作记要：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> <%= task.getServicelog()%></td>
					</tr>
					
					 <%if (task.getStatus() ==3){%>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">工分：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 

						 <%=task.getTaskscore()%>
							</td>
					</tr>
					<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">打分人：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 

						 <%=task.getScoreman()%>
							</td>
					</tr>
						<tr>
						<td height="24" align="right" bgcolor="#858585"><font
							color="#FFFFFF">打分日期：</font></td>
						<td bgcolor="#EDEDF0" style="padding-left:5px;"> 

						 <%=task.getScoretime()%>
							</td>
					</tr>
					<%}%>
					
           
                  
              		<tr>
						<td height="24" colspan="2" bgcolor="#D7D7DB"
							style="padding-left:10px;">明细信息：</td>
					</tr>
					<tr>
						<td bgcolor="#EDEDF0" style="padding: 3px 3px 3px 3px;"
							colspan="2">
						<table width="100%" border="0" cellpadding="0" cellspacing="1"
							bgcolor="#EDEDF0" id="tbDeviceDetail">
							<tr align="center" bgcolor="#D7D7DB">
								<td width="18%" height="24" bgcolor="#D7D7DB">取出部件PN</td>
								<td width="17%">取出部件SN</td>
								<td width="18%">装入部件PN</td>
								<td width="17%">装入部件SN</td>
								<td width="20%">文档</td>
								<td width="*%">描述</td>
							</tr>
					<%
                    list = task.getListDetail();
                    if (list != null && list.size() > 0) {
                    	for(int i=0;i<list.size();i++) {
                    		TaskDetail detail = (TaskDetail)list.get(i);
                    %>
							<tr align="center" bgcolor="#FFFFFF">
								<td height="24"><%=detail.getOutPartNo()%></td>
								<td><%=detail.getOutSerialNo()%></td>
								<td><%=detail.getRevPartNo()%></td>
								<td><%=detail.getSerialNo()%></td>
								<td><a href="do_download.jsp?filename=upload/taskDetail/<%=detail.getContextFile()%>" ><%=detail.getContextFile()%></a></td>
								<td><%=detail.getContextDesc()%></td>
							</tr>
							<%}}%>
							</table>
                    </td>
              </tr>
					<tr bgcolor="#EDEDF0">
						
						<td  align="center" colspan="6">
							
							
							
							   <input type="button" onClick="window.close();" name="btn" value="关闭" class="inputButton">  
							 <input type="hidden" name="cmd" value="">
							     
							 </td>
					</tr>
			</table>
          </td>
        </tr>
      
      </table>
        </form>
    </td>
  </tr>
</table>



</body>
</html>
